package cn.itcast.nems.studentrecord.service.impl;

import cn.itcast.nems.studentrecord.dto.change.StudentRecordChangeCheckOriginDTO;
import cn.itcast.nems.studentrecord.dto.change.StudentRecordTransactionChangeCheckDTO;
import cn.itcast.nems.studentrecord.enumeration.StudentRecordStateEnum;

import java.util.List;

/**
 * 检查学籍变更是否允许（升级）
 *
 * @author liyong
 * create: 2023-11-29 10:21:30
 **/
class StudentRecordChangeRenewalChecker extends StudentRecordChangeChecker {

    /**
     * 检查学籍是否可以变更
     *
     * @param studentRecordOrigin       要变更的源学籍
     * @param studentRecordTransactions 学员学籍流转记录
     */
    StudentRecordChangeRenewalChecker(StudentRecordChangeCheckOriginDTO studentRecordOrigin,
                                      List<StudentRecordTransactionChangeCheckDTO> studentRecordTransactions) {
        super(studentRecordOrigin, studentRecordTransactions);
    }

    /*
    @Override
    protected StudentRecordChangeCheckResult canChange(StudentRecordChangeCheckDTO dto) {
        super.canChange(dto);
        if (super.canChange) {
            final Boolean renewalFlag = super.studentRecordOrigin.getRenewalFlag();
            if (renewalFlag != null && renewalFlag) {
                super.reason = "基础班学籍已经升过级，不能再次升级";
                super.canChange = false;
            }
        }
        return new StudentRecordChangeCheckResult(super.canChange, super.reason);
    }
    */

    @Override
    void checkOriginStudentRecord() {
        if (!StudentRecordStateEnum.VALID.name().equals(this.studentRecordOrigin.getState())) {
            this.cannotChange("原班级学籍尚未生效");
        }
    }
}
